package com.vitabuybuy.tv.dialog

import android.app.Dialog
import android.content.Context
import android.graphics.drawable.ColorDrawable
import android.util.DisplayMetrics
import android.view.Gravity
import com.vitabuybuy.tv.R
import kotlinx.android.synthetic.main.dialog_bottomhint.*


/**
 * PackageName : com.ewhale.doctorhome.dialog
 * Author : Simga
 * Date : 2018/04/13
 * Time : 11:17
 */
class OptionsDialog(context: Context) : Dialog(context, R.style.Dialog) {

    init {
        this.setCanceledOnTouchOutside(true)
        setContentView(R.layout.dialog_bottomhint)

        buttonOne.setOnClickListener {
            onOneClick()
            dismiss()
        }
        buttonTwo.setOnClickListener {
            onTwoClick()
            dismiss()
        }
        buttonThree.setOnClickListener {
            dismiss()
        }
    }

    fun setBtnStr(btnStr01:String, btnStr02: String) {
        buttonOne.text = btnStr01
        buttonTwo.text = btnStr02
    }

    override fun onStart() {
        super.onStart()
        val window = window
        window?.setGravity(Gravity.BOTTOM) // 此处可以设置dialog显示的位置
        window?.setWindowAnimations(R.style.bottom_int_out_dialog_style) // 添加动画
        val dm = DisplayMetrics()
        window?.windowManager?.defaultDisplay?.getMetrics(dm)
        window?.setLayout(dm.widthPixels, window.attributes.height)
        window?.setBackgroundDrawable(ColorDrawable(0x00000000))
    }

    lateinit var onOneClick:()->Unit
    lateinit var onTwoClick:()->Unit
}
